public class xiersort {
     public void shell(int[] array){
         int gap = array.length;
         while(gap>1){
             gap = gap/2;
             sort(array,gap);
         }
     }

    private void sort(int[] array, int gap) {
         int i = gap;
        for ( ; i < array.length; i++) {
            int tem = array[i];
            int j = i-gap;
            for ( ; j >=0; j=j-gap) {
                 if(array[j] > tem){
                     array[j+gap] = array[j];
                 }
                 else {
                     break;
                 }
            }
            array[j+gap] = tem;
        }
    }

}
